package com.ruoyi.factorydata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.factorydata.mapper.CustomerLevelDataMapper;
import com.ruoyi.factorydata.domain.CustomerLevelData;
import com.ruoyi.factorydata.service.ICustomerLevelDataService;

/**
 * 客户等级数据Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-03
 */
@Service
public class CustomerLevelDataServiceImpl extends ServiceImpl<CustomerLevelDataMapper, CustomerLevelData> implements ICustomerLevelDataService {
    @Autowired
    private CustomerLevelDataMapper customerLevelDataMapper;

    /**
     * 查询客户等级数据
     *
     * @param id 客户等级数据主键
     * @return 客户等级数据
     */
    @Override
    public CustomerLevelData selectCustomerLevelDataById(Long id) {
        return customerLevelDataMapper.selectCustomerLevelDataById(id);
    }

    /**
     * 查询客户等级数据列表
     *
     * @param customerLevelData 客户等级数据
     * @return 客户等级数据
     */
    @Override
    public List<CustomerLevelData> selectCustomerLevelDataList(CustomerLevelData customerLevelData) {
        return customerLevelDataMapper.selectCustomerLevelDataList(customerLevelData);
    }

    /**
     * 新增客户等级数据
     *
     * @param customerLevelData 客户等级数据
     * @return 结果
     */
    @Override
    public int insertCustomerLevelData(CustomerLevelData customerLevelData) {
                customerLevelData.setCreateTime(DateUtils.getNowDate());
            return customerLevelDataMapper.insertCustomerLevelData(customerLevelData);
    }

    /**
     * 修改客户等级数据
     *
     * @param customerLevelData 客户等级数据
     * @return 结果
     */
    @Override
    public int updateCustomerLevelData(CustomerLevelData customerLevelData) {
                customerLevelData.setUpdateTime(DateUtils.getNowDate());
        return customerLevelDataMapper.updateCustomerLevelData(customerLevelData);
    }

    /**
     * 批量删除客户等级数据
     *
     * @param ids 需要删除的客户等级数据主键
     * @return 结果
     */
    @Override
    public int deleteCustomerLevelDataByIds(Long[] ids) {
        int i = customerLevelDataMapper.deleteBatchIds(Arrays.stream(ids).collect(Collectors.toList()));
        return i;
    }

    /**
     * 删除客户等级数据信息
     *
     * @param id 客户等级数据主键
     * @return 结果
     */
    @Override
    public int deleteCustomerLevelDataById(Long id) {
        return customerLevelDataMapper.deleteCustomerLevelDataById(id);
    }
}